import Vue from "vue";
import VueRouter from "vue-router";

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

Vue.use(VueRouter);

const routes = [
  { path: "/test1", component: () => import("@/views/test/test1.vue") },

  { path: "/login", component: () => import("@/views/login/index.vue") },
  { path: "/login/sms", component: () => import("@/views/login/sms.vue") },
  { path: "/login/token", component: () => import("@/views/login/token.vue") },
  {
    path: "/",
    component: () => import("@/layout"),
    name: "admin",
    children: [
      // { path:'/',component:()=>import('@/views/welcome.vue') }
      {
        path: "welcome",
        alias: "/",
        component: () => import("@/views/welcome.vue"),
        meta: { name1: "后台首页", name2: "欢迎页" },
      },
      // {
      //   path: "user/history",
      //   component: () => import("@/views/user/history.vue"),
      //   meta: { name1: "后台首页", name2: "访客记录" },
      // },
      // {
      //   path: "user",
      //   component: () => import("@/views/user"),
      //   meta: { name1: "用户管理", name2: "用户列表" },
      // },
      // {
      //   path: "user/create",
      //   component: () => import("@/views/user/create.vue"),
      //   meta: { name1: "用户管理", name2: "用户创建" },
      // },
      // {
      //   path: "role",
      //   component: () => import("@/views/role"),
      //   meta: { name1: "角色管理", name2: "角色列表" },
      // },
      // {
      //   path: "role/create",
      //   component: () => import("@/views/role/create.vue"),
      //   meta: { name1: "角色管理", name2: "角色创建" },
      // },
      // {
      //   path: "auth",
      //   component: () => import("@/views/auth"),
      //   meta: { name1: "权限管理", name2: "权限列表" },
      // },
      // {
      //   path: "auth/create",
      //   component: () => import("@/views/auth/create.vue"),
      //   meta: { name1: "权限管理", name2: "权限创建" },
      // },
    ],
  },
  {
    path: "*",
    component: () => import("@/views/404.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
